<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>所有分期支付记录</title>
<link rel="stylesheet" href="./css/left-nav.css">
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/record.css">
<style type="text/css">	
    .tableInfo{
    	margin-left: 500px;
    }
    body {
		background: url(https://images-1300275660.cos.ap-shanghai.myqcloud.com/caiwu3.png) no-repeat center;
	    background-attachment: fixed;
	    background-size: cover; 
	}
</style>
</head>
<body>
<!-- 左侧导航 -->
    <div class="left_nav" id="nav_left">
        <div class="head clearfix">
            <div class="head_icon"></div>
            <div class="head_word"><a href="home.jsp">返回首页</a></div>
        </div>
        <ul>
            <li>
                <span class="fourth_icon"></span>
               所有账单记录
            </li>
            
        </ul>
    </div>
<%	 	
	String url = "jdbc:mysql://localhost:3306/wacai?serverTimezone=Asia/Shanghai";
	Connection connection = null;
	Statement stmt = null;
	String sql = null;
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
	}catch(ClassNotFoundException exception){
		out.println("加载驱动器类时出现异常");
	}
		
	try{
		connection = DriverManager.getConnection(url,"root","root1234");//连接数据库
		sql = "select * from pay";
		stmt = connection.createStatement();
		ResultSet resultSet = stmt.executeQuery(sql);
		
		%>
		<div class="right">
			<table width="740" border="1" cellpadding="6" cellspacing="0" class="tableInfo">
			<caption>所有分期付款记录</caption>
			<tr class="tr1">
				<td width="110" height="30" align="center" valign="middle">付款金额(元)</td>
				<td width="100" align="center" valign="middle">付款方式</td>
				<td width="80" align="center" valign="middle">分期天数</td>
				<td width="100" align="center" valign="middle">付款日期</td>
				<td width="100" align="center" valign="middle">还款日期</td>
			</tr>
			
		<%
			while(resultSet.next()){
				
					String amount = resultSet.getString(1);
					String payMethod = resultSet.getString(2);
					String days = resultSet.getString(3);
					String payDay = resultSet.getString(4);
					String dueDay = resultSet.getString(5);
				%>
					<tr class="tr2">
						<td height="40" align="center" valign="middle"><%=amount %></td>
						<td align="center" valign="middle"><%=payMethod %></td>
						<td align="center" valign="middle"><%=days %></td>
						<td align="center" valign="middle"><%=payDay %></td>
						<td align="center" valign="middle"><%=dueDay %></td>
					</tr>
				<%
			}%>
			</table>	
		</div>	
	<%	
		resultSet.close();
		stmt.close();
		}catch(Exception e){
			out.print("<script type='text/javascript'>alert('查询失败');</script>");
			response.setHeader("Refresh","0.1;url=payType.jsp");
		}%>
</body>
</html>